home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / eulisp / comp0_89.lha / Feel / Boot / Compiler / rshow.em < prev    next >
Lisp/Scheme  |  1993-07-03  |  1KB  |  50 lines

  1. (defmodule rshow
  2.   (standard0) ()
  3.  
  4.   (defun show (object)
  5.     (mapcar (lambda (slot-name)
  6.           (format t "~a: ~a\n" slot-name
  7.               (slot-value object slot-name)))
  8.         (mapcar slot-description-name
  9.             (class-slot-descriptions (class-of object)))))
  10.  
  11.   (defun rshow (x)
  12.     (rshow-aux x ""))
  13.  
  14.   ;; same, but generic + recursive
  15.   (defun rshow-aux (x st)
  16.     (cond ((> (string-length st) 30)
  17.        (format t "..."))
  18.       (t (generic-rshow x st))))
  19.  
  20.  
  21.   (defgeneric generic-rshow (ob st))
  22.  
  23.   (defmethod generic-rshow (ob string)
  24.     (print ob)
  25.     (mapc (lambda (slot-name)
  26.           (format t "~a ~a:" string slot-name)
  27.           (rshow-aux (slot-value ob slot-name)
  28.              (string-append string "  ")))
  29.       (mapcar slot-description-name 
  30.           (class-slot-descriptions (class-of ob))))
  31.     nil)
  32.  
  33. ;;  (defmethod generic-rshow ((l pair) st)
  34. ;;     (format t "~a List: ~a\n" st (car l))
  35. ;;     (rshow-aux (car l) (string-append st "      "))
  36. ;;     (rshow-aux (cdr l) st))
  37.  
  38.   (defconstant Null (class-of nil))
  39.  
  40. ;;  (defmethod generic-rshow ((a Null) st)
  41. ;;    nil)
  42.           
  43.  
  44.   (export show)
  45.   (export rshow)
  46.   
  47.  
  48. ;;end module
  49.   )
  50.